<template>
  <div class="bankContainer">
    <el-form :key="formIndex" style="width: 30%;" :model="ruleForm" :rules="rules" ref="ruleForm" size="mini" label-width="70px" class="demo-ruleForm">
      <el-form-item label="工单号" prop="orderCode">
        <el-input clearable v-model="ruleForm.orderCode"></el-input>
      </el-form-item>
      <el-form-item label="结果" prop="orderResult">
        <el-select
          style="width: 100%;"
          filterable
          clearable
          v-model="ruleForm.orderResult"
          placeholder="请选择结果"
        >
          <el-option
            v-for="item in option"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import { dbResultNotice } from '@/api/bankBiz/loss/loss'
  export default {

    data() {
      return {
        formIndex: 0,
        option: [
          { 'label': '成功', 'value': '1' },
          { 'label': '拒绝', 'value': '2' },
          { 'label': '未呼叫成功', 'value': '3' },
        ],
        ruleForm: {
          orderCode: '',
          orderResult: ''
        },
        rules: {
          orderCode: [
            { required: true, message: '请输入工单号', trigger: 'blur' }
          ],
          orderResult: [
            { required: true, message: '请选择结果', trigger: 'change' }
          ]
        }
      }
    },
    created() {

    },
    mounted() {

    },
    methods: {
      submitForm(formName) {
        let _this = this
        _this.$refs[formName].validate((valid) => {
          if (valid) {
            _this.formIndex ++
            let params = {
              orderCode: _this.ruleForm.orderCode,
              orderResult: _this.ruleForm.orderResult
            }
            dbResultNotice(params).then(res => {
              if(res.data._RejCode === '000000'){
                window.globalUiKit.notify('提示', '提交成功', 'info')
              }else{
                window.globalUiKit.notify('提示', res.data.jsonError[0]._exceptionMessage, 'error')
              }
              // window.globalUiKit.notify('提示', res.data.retmsg, 'info')
            })
          } else {
            console.log('error submit!!')
            return false;
          }
        });
      },
      resetForm(formName) {
        this.formIndex ++
        this.$refs[formName].resetFields()
      }
    }
  }
</script>
<style scoped>
  .bankContainer .el-form-item {
    margin-bottom: 18px;
  }
</style>
